<?php
/**
 * Created by PhpStorm.
 * User: huqi
 * Date: 2019-12-29
 * Time: 03:26
 */

namespace WebUtil\Matrix\Layer;


class CrossSetLayer implements ILayer
{

    public function transform($input)
    {
        return array_reduce($input,function ($carry,$current){
            if (count($carry) == 0){
                return $current;
            }
            $rs = [];
            foreach ($carry as $item){
                foreach ($current as $item2){
                    $rs[] = array_merge($item,$item2);
                }
            }
            return $rs;
        },[]);
    }
}